import java.io.File;

public class MainClass {
	private final static String javaFileName = "C:/Users/Mykhailo_Savytskyi/workspace/ClassLoaders/src/TestModule.java";
	private final static String classFileName = "C:/Users/Mykhailo_Savytskyi/workspace/ClassLoaders/src/TestModule.class";

	void go() throws Exception {
		String progClass = "TestModule";
		MyClassLoader mc = new MyClassLoader(javaFileName, classFileName);

		Class<?> clas = mc.findClass(progClass);
		Object ob = clas.newInstance();
		System.out.println(ob);

	}

	public static void main(String[] args) throws Exception {

		MainClass mainc = new MainClass();
		mainc.go();

		while (true) {
			File javaFile = new File(javaFileName);
			File classFile = new File(classFileName);
			if (javaFile.lastModified() > classFile.lastModified()) {
				mainc.go();
			}
		}
	}
}
